<template>
  <div class="m-swiper_container" style="width: 1157.1px; min-height: 380px;">
    <div class="m-swiper_view">
      <div class="m-swiper_content">
        <ul class="m-swiper_list" style="width: 1740px; min-height: 380px; transform: translate3d(0px, 0px, 0px); transition: all 500ms ease-in-out 0s;">
          <div class="m-swiper_itemWrap slide " style="width: 290px; margin: 0px;" v-for="(hotelList,index) in SevenHotelList" :key='index' @click="toDetail(hotelList.hotel_id)">
            <div><a class="h-recommend-item" href="javascript:;">
                <div class="hotel-img">
                  <div class="hotel-ad"><span>广告</span></div><img :src="hotelList.main_photo" alt="">
                </div>
                <div class="hotel-info">
                  <h3 class="hotel-name" title=""><span>{{hotelList.name}}</span></h3>
                  <div class="hotel-level"><img src="http://webresource.c-ctrip.com/ResH5HotelOnline/R1/hotel_detail_icon_diamond4_20180824.png" alt="hotel-level"></div>
                  <div class="hotel-review"><span class="score">{{hotelList.health_score}}<em class="total">/5</em></span><span class="rating">很好</span><span class="comment">{{parseInt(Math.random()*(1500-1000+1)+1000)}}点评</span></div>
                  <div class="price-box"><span class="price-now"><dfn>¥</dfn>{{hotelList.min_price}}</span><span class="tax"></span></div>
                </div>
              </a></div>
          </div>
        </ul>
      </div>
      <div class="m-swiper_operate" v-if="SevenHotelList.length>4"><span class="m-swiper_arrow left hide" style="background-color: rgb(255, 255, 255); color: rgb(40, 125, 250); font-size: 20px; width: 48px; height: 48px; margin-top: -24px; box-shadow: rgba(0, 53, 128, 0.1) 0px 3px 8px 0px; left: -72px; padding-left: 8px; box-sizing: border-box;" onclick="this.parentNode.previousElementSibling.firstChild.style='width: 1740px; min-height: 380px; transform: translate3d(0px, 0px, 0px); transition: all 500ms ease-in-out 0s;';this.classList.add('hide');this.nextElementSibling.classList.remove('hide')"><i type="back" class="iconfont icon-arrow-left"></i></span><span class="m-swiper_arrow right " style="background-color: rgb(255, 255, 255); color: rgb(40, 125, 250); font-size: 20px; width: 48px; height: 48px; margin-top: -24px; box-shadow: rgba(0, 53, 128, 0.1) 0px 3px 8px 0px; right: -72px;" onclick="this.parentNode.previousElementSibling.firstChild.style='width: 1740px; min-height: 380px; transform: translate3d(-1160px, 0px, 0px); transition: all 500ms ease-in-out 0s;';this.classList.add('hide');this.previousElementSibling.classList.remove('hide')"><i type="arrowRight" class="iconfont icon-arrow-right"></i></span></div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'SwiperBox',
  props: {
    SevenHotelList: {
      type: Array,
      required: true
    }
  },
  methods: {
    toDetail(id) {
      this.$router.push('/hotel/detail/' + id)
      this.$store.dispatch('getHotelDetailInfo', id)
    }
  }
}
</script>

<style lang="scss" scoped>
.m-swiper_container {
  z-index: 1;
  position: relative;
  .m-swiper_view {
    width: 100%;
    height: 100%;
    position: relative;
    .m-swiper_content {
      width: 100%;
      height: 100%;
      overflow: hidden;
      position: relative;
      box-sizing: content-box;
      padding-left: 2px;
      padding-right: 2px;
      .m-swiper_list {
        display: table;
        position: relative;
        height: 100%;
        .m-swiper_itemWrap {
          height: 100%;
          float: left;
          position: relative;
          display: table-cell;
          &:first-of-type {
            margin-left: 0 !important;
          }
        }
        .h-recommend-item {
          display: block;
          width: 278px;
          .hotel-img {
            position: relative;
            width: 100%;
            height: 197px;
            img {
              display: block;
              width: 100%;
              height: 100%;
            }
          }
          .hotel-ad {
            position: absolute;
            opacity: 0.6;
            background: #333;
            border-radius: 2px;
            span {
              color: #fff;
              font-size: 12px;
            }
          }
          .hotel-info {
            box-sizing: border-box;
            padding-top: 8px;
            min-height: 130px;
            .hotel-name {
              width: 100%;
              font-size: 16px;
              line-height: 1.3;
              overflow: hidden;
              white-space: nowrap;
              text-overflow: ellipsis;
              color: #333;
            }
            .hotel-level {
              margin-top: 2px;
              img {
                height: 16px;
                width: auto;
                margin-bottom: 2px;
              }
            }
            .hotel-review {
              margin-top: 5px;
              font-size: 14px;
              .score {
                margin-right: 5px;
                font-size: 16px;
                color: #fff;
                padding: 1px 4px;
                background: #4978ce;
                border-radius: 4px 4px 0 4px;
                .total {
                  margin-left: 2px;
                  font-size: 12px;
                  color: #a8ccff;
                }
              }
              .rating {
                margin-right: 5px;
                color: #4978ce;
                font-weight: 700;
              }
              .comment {
                color: #8592a6;
              }
            }
            .price-box {
              margin-top: 15px;
              font-size: 14px;
              .price-now {
                margin-left: 4px;
                font-size: 18px;
                font-weight: 700;
                color: #287dfa;
              }
              .tax {
                font-size: 14px;
                color: #8592a6;
                text-align: right;
                line-height: 18px;
                margin-left: 5px;
              }
            }
          }
        }
      }
    }
    .m-swiper_operate {
      position: absolute;
      height: 0;
      top: 50%;
      margin-top: -12px;
      width: 100%;
      .m-swiper_arrow {
        position: absolute;
        width: 40px;
        height: 40px;
        background-color: rgba(0, 0, 0, 0.5);
        transform: translateY(-50%);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.09s ease-in-out;
      }
      .m-swiper_arrow.hide {
        display: none;
      }
      .m-swiper_arrow.prevent_hover {
        pointer-events: none;
      }
      .icon-arrow-left {
        font-size: 16px;
      }
    }
  }
  .icon-arrow-right {
    font-size: 30px;
  }
  .icon-arrow-left {
    font-size: 30px !important;
  }
}
</style>